#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include<stdlib.h>
void jishu(int* a, int n)
{
	int max = a[0];
	int min = a[0];
	for (int i = 0; i < n; i++)
	{
		if (a[i] > max)
		{
			max = a[i];
		}
		if (a[i] < min)
		{
			min = a[i];
		}
	}
	int len = max - min + 1;
	int* b = (int*)calloc(len,sizeof(int));
	for (int i = 0; i < n; i++)
	{
		b[(a[i] - min)]++;
	}
	int j = 0;
	for (int i = len-1; i >=0; i--)
	{
		if (b[i] != 0)
		{
			while (b[i]--)
			{
				a[j] = i + min;
				j++;
			}
		}
	}
}
int main()
{
	int a[] = { 1,312,23,34,23431,312 };
	jishu(a, 6);
	for (int i = 0; i < 6; i++)
	{
		printf("%d ", a[i]);
	}
	return 0;
}